/*
package com.ld.security.server.admin.modules.ge.wrapper;

import cn.hutool.core.date.SimpDateUtil;
import  com.ld.security.server.admin.modules.ge.constant.GeFieldConstant;
import  com.ld.security.server.admin.modules.ge.entity.GeFieldEntity;
import  com.ld.security.server.admin.modules.ge.po.DynModelPo;
import com.ld.security.common.core.exception.ApiException;
import com.ld.security.common.core.util.ReflectionUtil;
import com.ld.security.common.mybatis.core.wrapper.EntityWrapper;
import com.ld.security.common.mybatis.util.TreeUtil;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class TrendSqlFactory {

    //分组用时间
    private String groupTime="groupTime";

    private String args="args.";

    public EntityWrapper getParams(DynModelPo po, List rows) {


       List<GeFieldEntity> fields =  TreeUtil.treeToLink(po.getFields());


        EntityWrapper ew =  EntityWrapper.newInstance();



        //fields = fields.stream().filter(v -> v.getCollectType() == GeFieldConstant.collectType.group).collect(Collectors.toList());


        //分组的字段,一定是静态查询条件
        for (GeFieldEntity field : fields) {


            List list =  new LinkedList<>();


            for (Object row : rows) {
                Object v = ReflectionUtil.invokeGetter(row, field.getFieldName());

                if(ReflectionUtil.isNull(v)){
                    continue;
                }
                GeFieldConstant.dataFomat dataFomat =  field.getDataFomat();



                if(field.getFieldType() == GeFieldConstant.fieldType.date_time){

                    Date date=null;
                    if(v instanceof String){
                        date =  dataFomat.parseDate((String)v);
                    }else if(v instanceof Date){
                        date = (Date)v;
                    }else{
                        throw  new ApiException(400,"异常时间");
                    }

                    switch (dataFomat){
                        case day: {
                            date = SimpDateUtil.offsetDay(date, -1);
                            break;
                        }
                        case week: {
                            date = SimpDateUtil.offsetWeek(date, -1);
                            break;
                        }
                        case month: {
                            date = SimpDateUtil.offsetMonth(date, -1);
                            break;
                        }
                        case year: {
                            date = SimpDateUtil.offsetMonth(date, -12);
                            break;
                        }default:{
                            throw new ApiException(400,"非趋势字段");
                        }

                    }
                    list.add(dataFomat.fomatDate(date));
                }else{
                    list.add(v);
                }

            }
            if(list.isEmpty()){
                continue;
            }
            ew.in(field.getFieldName(),list);
        }


        return ew;
    }


    public String getSql(String sql) {

        StringBuffer sb =  new StringBuffer();

        sb.append("select * from ("+sql+") as sys_def ");

        return sb.toString();

    }
}
*/
